/*
 * ActionGo.h
 *
 *  Created on: 09/giu/2011
 *      Author: lugas
 */

#ifndef ACTIONGO_H_
#define ACTIONGO_H_
#include "Aria.h"

/*
 * Action that drives the robot forward, but stops if obstacles are
 * detected by sonar.
 */
class ActionGo: public ArAction {
public:
	// constructor, sets myMaxSpeed and myStopDistance
	ActionGo(double maxSpeed, double stopDistance, double controlAngle);
	// destructor. does not need to do anything
	virtual ~ActionGo(void) {
	}
	;
	// called by the action resolver to obtain this action's requested behavior
	virtual ArActionDesired *fire(ArActionDesired currentDesired);
	// store the robot pointer, and it's ArSonarDevice object, or deactivate this action if there is no sonar.
	virtual void setRobot(ArRobot *robot);
	double myMaxSpeed;
protected:
	// the sonar device object obtained from the robot by setRobot()
	ArRangeDevice *mySonar;

	/* Our current desired action: fire() modifies this object and returns
	 to the action resolver a pointer to this object.
	 This object is kept as a class member so that it persists after fire()
	 returns (otherwise fire() would have to create a new object each invocation,
	 but would never be able to delete that object).
	 */
	ArActionDesired myDesired;


	double myStopDistance;
	double myControlAngle;

};

#endif /* ACTIONGO_H_ */
